package com.atguigu0.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @description: xxx
 * @time: 2020/6/12 22:26
 * @author: baojinlong
 **/
object TestSearch {
  def main(args: Array[String]): Unit = {
    val sparkConf: SparkConf = new SparkConf().setAppName("myWordCount").setMaster("local[*]")
    // 创建sparkContext对象
    val sc: SparkContext = new SparkContext(sparkConf)
    // 创建一个RDD
    val word: RDD[String] = sc.makeRDD(Array("a", "b", "c", "d"))
    // 创建search对象
    val search = new Search("a")
    // 对rdd进行过滤,只有跟rdd相关操作的变量才需要被传送到executor中
    val filter: RDD[String] = search.getMatch2(word)
    // 打印
    filter.foreach(println)
    // 关闭资源
    sc.stop()

  }
}
